﻿using System;

    namespace Framework
    {
        public class EventDispatcher : IEventDispatcher, IModuleEventDispatcher
        {
            private EventTable _eventTable;

            public EventDispatcher()
            {
                _eventTable = new EventTable();
            }

            public void AddListener<T>(string eventName, Action<T> handler)
            {
                _eventTable.Add<T>(eventName, handler);
            }

            public void AddListener(string eventName, Action handler)
            {
                _eventTable.Add(eventName, handler);
            }

            public void AddListener<T, U>(string eventName, Action<T, U> handler)
            {
                _eventTable.Add<T, U>(eventName, handler);
            }

            public void AddListener<T, U, V>(string eventName, Action<T, U, V> handler)
            {
                _eventTable.Add<T, U, V>(eventName, handler);
            }

            public void AddListener<T, U, V, W>(string eventName, Action<T, U, V, W> handler)
            {
                _eventTable.Add<T, U, V, W>(eventName, handler);
            }

            public void Cleanup()
            {
                _eventTable.Cleanup();
            }
            
            public void Dispose()
            {
                _eventTable.Cleanup();
                _eventTable = null;
            }

            public void RemoveEvents(string eventName)
            {
                _eventTable.RemoveEvents(eventName);
            }

            public void RemoveListener(string eventName, Action handler)
            {
                _eventTable.Remove(eventName, handler);
            }

            public void RemoveListener<T>(string eventName, Action<T> handler)
            {
                _eventTable.Remove<T>(eventName, handler);
            }

            public void RemoveListener<T, U>(string eventName, Action<T, U> handler)
            {
                _eventTable.Remove<T, U>(eventName, handler);
            }

            public void RemoveListener<T, U, V>(string eventName, Action<T, U, V> handler)
            {
                _eventTable.Remove<T, U, V>(eventName, handler);
            }

            public void RemoveListener<T, U, V, W>(string eventName, Action<T, U, V, W> handler)
            {
                _eventTable.Remove<T, U, V, W>(eventName, handler);
            }

            public void TriggerEvent(string eventName)
            {
                _eventTable.TriggerEvent(eventName);
            }

            public void TriggerEvent<T>(string eventName, T arg1)
            {
                _eventTable.TriggerEvent<T>(eventName, arg1);
            }

            public void TriggerEvent<T, U>(string eventName, T arg1, U arg2)
            {
                _eventTable.TriggerEvent<T, U>(eventName, arg1, arg2);
            }

            public void TriggerEvent<T, U, V>(string eventName, T arg1, U arg2, V arg3)
            {
                _eventTable.TriggerEvent<T, U, V>(eventName, arg1, arg2, arg3);
            }

            public void TriggerEvent<T, U, V, W>(string eventName, T arg1, U arg2, V arg3, W arg4)
            {
                _eventTable.TriggerEvent<T, U, V, W>(eventName, arg1, arg2, arg3, arg4);
            }

            public void AddModuleListener<T>(string eventName, Action<T> handler)
            {
                _eventTable.Add(eventName, handler);
            }

            public void AddModuleListener(string eventName, Action handler)
            {
                _eventTable.Add(eventName, handler);
            }

            public void AddModuleListener<T, U>(string eventName, Action<T, U> handler)
            {
                _eventTable.Add(eventName, handler);
            }

            public void AddModuleListener<T, U, V>(string eventName, Action<T, U, V> handler)
            {
                _eventTable.Add(eventName, handler);
            }

            public void AddModuleListener<T, U, V, W>(string eventName, Action<T, U, V, W> handler)
            {
                _eventTable.Add(eventName, handler);
            }

            public void CleanupModuleEvents()
            {
                _eventTable.Cleanup();
            }

            public void RemoveModuleEvents(string eventName)
            {
                _eventTable.RemoveEvents(eventName);
            }

            public void RemoveModuleListener(string eventName, Action handler)
            {
                _eventTable.Remove(eventName, handler);
            }

            public void RemoveModuleListener<T>(string eventName, Action<T> handler)
            {
                _eventTable.Remove(eventName, handler);
            }

            public void RemoveModuleListener<T, U>(string eventName, Action<T, U> handler)
            {
                _eventTable.Remove(eventName, handler);
            }

            public void RemoveModuleListener<T, U, V>(string eventName, Action<T, U, V> handler)
            {
                _eventTable.Remove(eventName, handler);
            }

            public void RemoveModuleListener<T, U, V, W>(string eventName, Action<T, U, V, W> handler)
            {
                _eventTable.Remove(eventName, handler);
            }

            public void TriggerModuleEvent(string eventName)
            {
                _eventTable.TriggerEvent(eventName);
            }

            public void TriggerModuleEvent<T>(string eventName, T arg1)
            {
                _eventTable.TriggerEvent(eventName, arg1);
            }

            public void TriggerModuleEvent<T, U>(string eventName, T arg1, U arg2)
            {
                _eventTable.TriggerEvent(eventName, arg1, arg2);
            }

            public void TriggerModuleEvent<T, U, V>(string eventName, T arg1, U arg2, V arg3)
            {
                _eventTable.TriggerEvent(eventName, arg1, arg2, arg3);
            }

            public void TriggerModuleEvent<T, U, V, W>(string eventName, T arg1, U arg2, V arg3, W arg4)
            {
                _eventTable.TriggerEvent(eventName, arg1, arg2, arg3, arg4);
            }
        }
    }
